home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / infield2.zip / INFIELD.DOC < prev    next >
Text File  |  1993-01-04  |  13KB  |  243 lines

  1.                              INFIELD USER'S GUIDE
  2.  
  3.                                   Version 2.0
  4.                                February 10, 1989
  5.  
  6.  
  7.                                             _______                    
  8.                                        ____|__     |               (tm)
  9.                                     --|       |    |-------------------
  10.         Menne Computers               |   ____|__  |  Association of   
  11.   W277 S4455 Elk Valley Court         |  |       |_|  Shareware        
  12.    Waukesha, WI  53188-6437           |__|   o   |    Professionals    
  13.                                     -----|   |   |---------------------
  14.                                          |___|___|    MEMBER           
  15.                                                                        
  16.  
  17.      This general data input routine is written in Turbo Pascal version 5.0.  
  18. Below is the interface section of the unit.  The unit is designed to work with 
  19. QWIK42B.TPU, compiled under TP5. 
  20. ------------------------------------------------------------------------------
  21. Unit InField;
  22.  
  23. Interface
  24. Uses Crt, Qwik;
  25.  
  26. type Strng80 = string[80];
  27.  
  28. var    SOE, COE, EOB,             { Abbreviations mean:                     }
  29.        EOA, ISnd, Kclk,           { Strip On Exit,                      SOE }
  30.        ESTP, HomEnd,              { Clear On Entry,                     COE }
  31.        UseTemp, Keeptemp,         { ESC On Blank,                       EOB }
  32.        CapsOnly, MOK,             { Exit on Arrow (up or down) key      EOA }
  33.        LfRt, Flush,               { Sound,                             Isnd }
  34.        IExit           : boolean; { Keyclick,                          Kclk }
  35.                                   { Strip off end spaces               ESTP }
  36.                                   { Cursor placement when called     HomEnd }
  37.                                   { Use a Template                  UseTemp }
  38.                                   { Keep Template in rtn string    KeepTemp }
  39.                                   { All letters capitalized        CapsOnly }
  40.                                   { Move cursor on key in template      MOK }
  41.                                   { Exit on Arrow (left or right)      LfRt }
  42.                                   { Flush Left (false) or right       Flush }
  43.                                   { Global exit flag                  IExit }
  44.           FKey, TAttr : integer;  { Function key number,               Fkey }
  45.                                   { Template attribute,               TAttr }
  46.            StCh, EnCh : char;     { Starting and ending character.          }
  47.              Template : Strng80;  { Template string                         }
  48.  
  49.  
  50.  
  51. procedure Data_In(Drow, Dcol, MaxWide : integer;
  52.                           Var InWord : Strng80;
  53.                                Dattr : integer);
  54.  
  55. procedure  BadChoice;
  56. procedure  Strip(Var Stripit : String);
  57. function   StrOf(Count, Ascii : byte ) : String;
  58. function   Strcmp(Astr1, Astr2 : String) : shortint;
  59.  
  60.      
  61.  
  62. Implementation
  63. -----------------------------------------------------------------
  64.  
  65.       This is a general data input unit that far outperforms the rest, yet is
  66. much smaller that others I have seen (only 7k). The basic screen output is
  67. handled by Eagle Performance Software's excellent Qwik routines. (QWIK42B.ARC
  68. - You bet I registered!)  You set the starting row and column (Beware of
  69. setting DRow to X and DCol to Y, the normal order for GotoXY.  If you don't 
  70. like this, register the LeMay Qwik utility and use GotoRC like I do!), the
  71. maximum width of the field (this has no effect when you use templates), the 
  72. string to edit and the color of the field.  Here is a run down of the various 
  73. other features: 
  74.  
  75. EDITING - It acts like a mini-wordprocessor on a line!  You toggle insert 
  76.           mode with Ins, and the cursor will get larger in insert mode and
  77.           smaller in overwrite.  The cursor is restored to what it was on 
  78.           exit.  Word right and Word left (Ctrl-arrows) works, and 
  79.           PgDn=End=Ctrl-PgDn=Ctrl-End, as well as 
  80.           PgUp=Home=Ctrl-PgUp=Ctrl-Home.  Del and BackSpace are implemented,
  81.           but Tab has no effect.
  82.  
  83. SOUND - Can be turned on and off through ISnd.  You can also enable a 
  84.         keyclick with the Kclk variable.  Sound is output when an invalid 
  85.         key is pressed, or when you are at the end of the data field, or 
  86.         when you press ESC.  The global procedure BadChoice is the procedure
  87.         that makes the sound when you press an invalid key.
  88.  
  89. CLEAR ON ENTRY - if you want the text to be initialized with spaces when
  90.                  entering the routine, then set COE to TRUE. Otherwise, the
  91.                  current string is displayed in the field, and pressing
  92.                  Return will accept that string.
  93.  
  94. STRIP ON EXIT - If you want to get rid of all spaces and nulls after the text
  95.                 is input, set SOE to TRUE, otherwise the string will be left
  96.                 alone.  The global procedure Strip does the stripping.
  97.  
  98. END STRIP - This strips off all trailing spaces on exit.  This works 
  99.             independently from the other strip functions.  There is no
  100.             procedure available to the user to do this, mainly because of 
  101.             variable constraints. 
  102.  
  103.  
  104. COLORS - the attribute byte, Dattr, specifies the main text color.  The
  105.          global variable, Tattr, specifies the template attribute.  Both of
  106.          these variables are set by the following equation:
  107.               Attr := (background shl 4) + foreground;
  108.          Using Turbo Pascal's color constants is even more friendly:
  109.               Attr := (Blue shl 4) + White;
  110.          You can also specify what the characters at the beginning and end
  111.          of the field are through StCh and EnCh.  StCh refers to the
  112.          starting character.  EnCh refers to the ending character.  To disable
  113.          having a starting and/or an ending character, set StCh and/or EnCh to
  114.          'N'.  By the way, if Tattr <> 255, then StCh and EnCh will be ouput 
  115.          using Tattr, the template attribute.  Otherwise, they will use the 
  116.          normal text color (Tattr = 255, the default).  This is done so that
  117.          you won't have to change Tattr every time you change colors in your 
  118.          program.  
  119.  
  120. CAPSONLY - Forces all characters input to be upper case.
  121.  
  122. LEFT & RIGHT ARROW EXIT - In most cases, you simply wish the up and down
  123.                           arrows to exit, not the left and right arrows,
  124.                           which are useful for editing.  If you wish to
  125.                           exit on the left and right arrow, then set
  126.                           LfRt to TRUE.  The default is FALSE.
  127.  
  128. FLUSH LEFT OR RIGHT - This variable controls whether to flush the give
  129.                       string in InWord left or right in the field (moot
  130.                       point if you've set Clear on Entry to TRUE).  If
  131.                       Flush = false, then the data will be left justified,
  132.                       else the data will be right justified.
  133.  
  134. HOME OR END CURSOR - This variable causes the cursor to be placed at the
  135.                      beginning of the data or the end of the data.  If it
  136.                      is TRUE, the cursor will be put to the beginning of
  137.                      the data.  If FALSE, it will be put at the end.  The
  138.                      default is FALSE.
  139.  
  140. TEMPLATES - You can specify a template around which text will be entered.
  141.             For instance, "  /  /  " can be used for dates "        .   "
  142.             can be used for file names, etc.  When you enter text, the text
  143.             "flows" around the characters in the template.  The template is
  144.             specified by setting the global string variable, Template, to 
  145.             what you want.  
  146.             To use the template, set the global variable UseTemp to TRUE.
  147.             You also have the option of leaving the template in the inputted 
  148.             text.  This is set through the KeepTemp variable.  For example, 
  149.             with KeepTemp FALSE, and a template of "  /  /  ", if you input 
  150.             "06/04/88", the result in InWord is "060488".  But if you set 
  151.             KeepTemp to TRUE, the result will be "06/04/88".
  152.             A further option with templates is the Move On Key feature.  
  153.             When MOK is TRUE, and the user presses a character that is TO
  154.             THE RIGHT of the cursor position, the cursor position will move 
  155.             to one space after the character in the template.  To explain, 
  156.             say you have a template "        .   ", and the screen looks 
  157.             like this:
  158.                  "INTEST▄ .   "
  159.             and the user presses the "." key.  The screen will then look
  160.             like this:
  161.                  "INTEST  .▄  "
  162.             It doesn't matter how many of the same characters you have in 
  163.             the field, either.  For instance, if the screen looked like this: 
  164.                  "AK005-7721-31 -41▄   -    -   " 
  165.             and the user presses the "-" key, the screen will look like this: 
  166.                  "AK005-7721-31 -41    -▄   -   "
  167.             When MOK is false, of course, none of this happens.
  168.  
  169. PROGRAMMING - Say you want pop up help from this field?  Say you have 
  170.               several fields and you want to cursor through them?  Infield 
  171.               handles these problems, too.  Any regular, shifted, 
  172.               controlled, or alted (alted?) function key will set the global 
  173.               exit flag, Iexit,  to TRUE, and the key number will be left in
  174.               FKey.  By the way, the key number for the last key pressed
  175.               before exiting is ALWAYS left in Fkey.  See the reference 
  176.               section of the Turbo Pascal manual for the key numbers.  If 
  177.               you want to exit on any cursor key, set EOA to TRUE.  This
  178.               workes for Up, Down, Left and Right arrow keys, so the Right 
  179.               and Left arrow keys are no longer available for editing.  This 
  180.               is when the EOA flag comes into play, also.  If you wish to
  181.               check if the user pressed return on an empty field, set EOA to 
  182.               TRUE.  Then, if they do that, the global exit flag Iexit will
  183.               be set to TRUE.  Fkey will contain 13, the key number for
  184.               Return. 
  185.  
  186.  
  187. INCLUDED ROUTINES - There are several lightning quick machine language 
  188.                     routines which I have included.  Strip allows you
  189.                     to remove all whitespace characters from a string,
  190.                     including char #32, #00, and #255.  It does NOT 
  191.                     remove anything else (such as #13, #10, etc.).  StrOf
  192.                     returns a string that is Count characters long, containing
  193.                     the ASCII character specified by Ascii.  Strcmp is an
  194.                     extremely fast string comparison routine which returns a
  195.                     0 if the two strings are equal, a -1 if Astr1 is less than
  196.                     Astr2, and a 1 if Astr1 is greater than Astr2.  BadChoice
  197.                     makes a sound to indicate an error.
  198.  
  199.  
  200. DEFAULTS:
  201.    Iexit := false;   
  202.      SOE := false;   
  203.      COE := false;
  204.      EOB := false;
  205.      EOA := false;  
  206.     ISnd := true;
  207.     Kclk := false;
  208.  UseTemp := false;
  209.     Fkey := 0;
  210.     StCh := '[';
  211.     EnCh := ']';
  212. KeepTemp := false;
  213. Template := '';
  214.    TAttr := 255;      { A change from last time. }
  215.      MOK := false;
  216. CapsOnly := false;
  217.     ESTP := true;
  218.     LfRt := false;
  219.    Flush := false;
  220.   HomEnd := false;
  221.  
  222.  
  223. If you like this unit and use it, please donate $10 to my college education.
  224. Even just a letter that reports a bug is GREATLY appreciated.  If you send 
  225. anything at all, you would reap several benefits.  Not only would feel great 
  226. for supporting the Shareware concept, you will have one up on your computer 
  227. friends ("When was the last time YOU registered for a piece of Shareware 
  228. software?" etc.)  Send to: 
  229.  
  230.     Menne Computers
  231.     Kevin Menningen
  232.     W277 S4455 Elk Valley Ct.
  233.     Waukesha, WI  53188-6437
  234.  
  235. I have an account on Exec-PC BBS, (414) 964-5160, the LARGEST BBS in the 
  236. world.  75+ lines (I can never remember how many), 1.31+ gigibyte hard disk 
  237. and PC SIG CD-ROM.  This is a pay system (only $60 for an 4 meg/week for a 
  238. year), so you cannot leave mail to me unless you have an account.  However, 
  239. feel free to check it out through Telenet Direct Connect, PC Pursit or the 
  240. normal telephone network. 
  241.  
  242.  
  243.